//
//  WD_HomeDetailUserCell.m
//  BUDING
//
//  Created by HanWoonYong on 16/4/6.
//  Copyright © 2016年 HanWoonYong. All rights reserved.
//

#import "WD_HomeDetailUserCell.h"

@implementation WD_HomeDetailUserCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.headView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:self.headView];
        self.userName = [[UILabel alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:self.userName];
        self.message = [[UILabel alloc] initWithFrame:CGRectZero];
        self.message.numberOfLines = 3;
        [self.contentView addSubview:self.message];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.headView.frame = CGRectMake(10, 10, 60, 60);
    CALayer *layer = [self.headView layer];
    [layer setMasksToBounds:YES];
    [layer setCornerRadius:self.headView.bounds.size.width / 2];
    self.userName.frame = CGRectMake(self.headView.frame.size.width + 20, self.headView.frame.origin.y, WIDTH, 30);
    self.message.frame = CGRectMake(self.userName.frame.origin.x, self.userName.frame.size.height, WIDTH, 60);
}

- (void)setUser:(WD_MovieUserModel *)user {
    _user = user;
    [self.headView sd_setImageWithURL:[NSURL URLWithString:[_user.avatar objectForKey:@"url"]]];
    self.userName.text = _user.nickname;
    self.message.text = _user.intro;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
